﻿using System.Text;
using System.Collections.Specialized;
using Newtonsoft.Json;

namespace CometDocs
{
    internal partial class Client
    {
        /// <summary>
        /// Delete a folder: https://www.cometdocs.com/developer/apiDocumentation#method-deleteFolder
        /// </summary>
        /// <param name="token">A valid authentication token.</param>
        /// <param name="folder">The folder to delete.</param>
        public void DeleteFolder(AuthenticationToken token, FolderInfo folder)
        {
            NameValueCollection @params = new NameValueCollection(2);
            @params.Add("token", token.Value);
            @params.Add("id", folder.ID.ToString());

            byte[] result = webClient.UploadValues(APIRoot + "deleteFolder", @params);

            string json = Encoding.ASCII.GetString(result);

            Response response = JsonConvert.DeserializeObject<Response>(json);

            CheckAndThrow(response);
        }
    }
}
